import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TComprehensionTargetCondition } from "../../../Message/Db/Tables/TComprehensionTargetCondition";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class TargetConditionConfig
    
    export  class TargetConditionConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (TargetConditionConfig._instace != null) 
            {
                throw new Error("TargetConditionConfig 单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_comprehension_target_condition.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TComprehensionTargetCondition();
                loc1.chapterCode = loc2.chapterCode;
                loc1.conditionType = loc2.conditionType;
                loc1.contents = StringHelper.getString(loc2.contents);
                loc1.day = loc2.day;
                loc1.openTime = loc2.openTime;
                loc1.timeLimit = loc2.timeLimit;
                loc1.timeLimitType = loc2.timeLimitType;
                loc1.dayTitle = loc2.dayTitle;
                loc1.dayDesc = loc2.dayDesc;
                loc1.position = StringHelper.getString(loc2.position);
                loc1.mod = StringHelper.getString(loc2.mod);
                this._map[loc1.day] = loc1;
            }
            return;
        }

        public getConditionByChapterCode(arg1: int): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            var loc4=this._map;
            for(loc2 of loc4) 
            {
                if (!(loc2.chapterCode == arg1 && loc2.conditionType > 0)) 
                {
                    continue;
                }
                loc1.push(loc2);
            }
            return loc1;
        }

        public getConditionByDay(arg1: int): TComprehensionTargetCondition
        {
            return this._map[arg1];
        }

        public getConditionMap(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._map;
        }

        public static get instance(): TargetConditionConfig
        {
            if (TargetConditionConfig._instace == null) 
            {
                TargetConditionConfig._instace = new TargetConditionConfig();
            }
            return TargetConditionConfig._instace;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instace: TargetConditionConfig;
    }
